package d1016.r212.num27;

import java.util.Scanner;

public class Person {
    //属性
    private String name;

    public Person(String name) {
        super();
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    //方法  买书
    public Book buy(Book[] books){
        Book book=null;//用户要买的书
        System.out.println("请输入购书的编号");
        Scanner sc=new Scanner(System.in);
        int id=sc.nextInt();
        //遍历数组
        for(int i=0;i<books.length;i++){
            Book book2=books[i];//数组中的每一个元素
            if(book2.getId()==id){
                book=book2;
                break;
            }
        }
        return book;
    }

}

